#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

int main() {
    int m, n, t;
    scanf("%d %d", &n, &m);
    int arr[2000] = { 0 };
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        arr[t] = 1;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &t);
        arr[t] = 1;
    }
    for (int i = 0; i < 2000; i++)
    {
        if (arr[i] == 1)
            printf("%d", i);
    }
    return 0;
}